package com.example.myapplication.network.api

import com.example.myapplication.network.core.RetrofitFactory
import retrofit2.http.GET

data class Product(
    val spuId: Int,
    val title: String,
    val subTitle: String,
    val coverImage: String,
    val displayPrice: String,
    val commentCount: Int,
    val id: String
)

data class ProductDetail(
    val spu:ProductSpu,
    val specs:List<Sepc>,
    val skus: List<Sku>
)

data class ProductSpu(
    val id: Int,
    val title: String,
    val subTitle: String,
    val description: String,
    val coverImage: String,
    val categoryId: Int,
    val imageList:List<String>,
    val videoUrl: String,
    val detailHtml: String
)

data class Sepc(
    val id: Int,
    val name: String,   //规格维度的名称（颜色、存储容量、尺寸）
    val affectPrice: Int,
    val values:List<SpecValue>,
)

data class SpecValue(
    val id: Int,
    val specId: Int,    //规格维度的id
    val value: String,  //规格维度id下对应的值
    val sort: Int,
)

data class Sku(
    val skuId: Int,
    val price: Int,
    val stock: Int,
    val imageUrl: String,
    val specValues: List<SpecValue>,
)

interface ProductApiService{
    //获取ProductApiService的实例对象
    companion object{
        fun getInstance(): ProductApiService{
            return RetrofitFactory.create(ProductApiService::class.java)
        }
    }

    @GET("/products")
    suspend fun getProducts(): List<Product>

    @GET("/details")
    suspend fun getProductDetail(): ProductDetail
}